package erfgame.core.util;

import org.junit.Test;


import erfgame.core.Point3D;
import erfgame.core.util.ColorUtils;
import erfgame.core.world.terrain.VerticalLightAngleVoxelColorPicker;



public class ColorUtilsTester {

	public ColorUtilsTester() {
	}

	@Test
	public void testGetPathDeltasOblique() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								0, 0, 0, 0, 0, 1
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								0, 0, 0, 0, 1, 1
							}
						},
						// x = 2
						{
							{
								0, 0, 0, 1, 1, 1
							}
						},
						// x = 3
						{
							{
								0, 0, 1, 1, 1, 1
							}
						},
						// x = 4
						{
							{
								0, 1, 1, 1, 1, 1
							}
						},
						// x = 5
						{
							{
								1, 1, 1, 1, 1, 1
							}
						}
					}
				}
			}
		};
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, false);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				2, 0, 3, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED,
				false, 
				result, 
				turn,
				false
		);
		System.out.println( result );
		System.out.println( turn );
	}
	
	@Test
	public void testGetPathDeltasVertical() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								0, 0, 0, 0, 0, 0
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								0, 0, 0, 0, 0, 0
							}
						},
						// x = 2
						{
							{
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 3
						{
							{
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 4
						{
							{
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 5
						{
							{
								1, 1, 1, 1, 1, 1
							}
						}
					}
				}
			}
		};
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, true);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				2, 0, 3, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false, 
				result, 
				turn,
				false
		);
		System.out.println( result );
	}

	@Test
	public void testGetPathDeltasVertical2() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								1, 1, 1, 1, 1, 1
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 2
						{
							{
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 3
						{
							{
								0, 0, 0, 0, 0, 0
							}
						},
						// x = 4
						{
							{
								0, 0, 0, 0, 0, 0
							}
						},
						// x = 5
						{
							{
								0, 0, 0, 0, 0, 0
							}
						}
					}
				}
			}
		};
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, true);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				2, 0, 3, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false,
				result, 
				turn,
				false
		);
		System.out.println("vertical 2");
		System.out.println( result );
	}
	

	@Test
	public void testGetPathDeltasRightAngle() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								1, 1, 1, 0, 0, 0
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								1, 1, 1, 0, 0, 0
							}
						},
						// x = 2
						{
							{
								1, 1, 1, 0, 0, 0
							}
						},
						// x = 3
						{
							{
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 4
						{
							{
								1, 1, 1, 1, 1, 1
							}
						},
						// x = 5
						{
							{
								1, 1, 1, 1, 1, 1
							}
						}
					}
				}
			}
		};
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, true);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				2, 0, 2, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false,
				result, 
				null,
				false
		);
		System.out.println("right angle");
		System.out.println( result );
	}


	@Test
	public void testGetPathDeltasRightAngleOut() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								0, 0, 0, 0, 0, 0
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								0, 0, 0, 0, 0, 0
							}
						},
						// x = 2
						{
							{
								0, 0, 0, 0, 0, 0
							}
						},
						// x = 3
						{
							{
								1, 1, 1, 0, 0, 0
							}
						},
						// x = 4
						{
							{
								1, 1, 1, 0, 0, 0
							}
						},
						// x = 5
						{
							{
								1, 1, 1, 0, 0, 0
							}
						}
					}
				}
			}
		};
		System.out.println("right angle out");
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, true);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				3, 0, 2, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false,
				result, 
				turn,
				false
		);
		System.out.println( result );
		System.out.println( turn );
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn2 = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				3, 0, 1, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false, 
				result, 
				turn2,
				false
		);
		System.out.println( result );
		System.out.println( turn2 );
	}
	
	@Test
	public void testGetPathDeltasGutter() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								0, 0, 0, 1, 1, 1
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								0, 0, 0, 1, 1, 1
							}
						},
						// x = 2
						{
							{
								0, 0, 0, 1, 1, 1
							}
						},
						// x = 3
						{
							{
								0, 0, 0, 0, 1, 1
							}
						},
						// x = 4
						{
							{
								0, 0, 0, 0, 1, 1
							}
						},
						// x = 5
						{
							{
								0, 0, 0, 0, 1, 1
							}
						}
					}
				}
			}
		};
		
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, true);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				2, 0, 3, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false, 
				result, 
				turn,
				false
		);
		System.out.println("gutter");
		System.out.println( result );
		System.out.println( turn );
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn2 = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				4, 0, 4, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				false, 
				result, 
				turn2,
				false
		);
		System.out.println( result );
		System.out.println( turn2 );
	}

	@Test
	public void testGetPathBump() {
		Point3D result = new Point3D();
		byte[][][][][][] terrain = new byte[][][][][][]{
			{
				{
					{   // x = 0
						{ // y = 0
							{ 
								// z = 0..5 
								0, 0, 0, 1, 1, 1
							}
						},
				        // x = 1 
						{ 
							// y = 0
							{ 
								// z = 0..5
								0, 0, 0, 1, 1, 1
							}
						},
						// x = 2
						{
							{
								0, 0, 0, 1, 1, 1
							}
						},
						// x = 3
						{
							{
								0, 0, 1, 1, 1, 1
							}
						},
						// x = 4
						{
							{
								0, 0, 1, 1, 1, 1
							}
						},
						// x = 5
						{
							{
								0, 0, 0, 1, 1, 1
							}
						}
					}
				}
			}
		};
		
		VerticalLightAngleVoxelColorPicker colorUtils;
		colorUtils = new VerticalLightAngleVoxelColorPicker(Math.PI/6, 16, null, 6, 1, 6, true);
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				2, 0, 3, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				true, 
				result, 
				turn,
				false
		);
		System.out.println("bump");
		System.out.println( result );
		System.out.println( turn );
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn2 = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				5, 0, 3, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				true, 
				result, 
				turn2,
				false
		);
		System.out.println( result );
		System.out.println( turn2 );
		VerticalLightAngleVoxelColorPicker.VerticalEdge turn3 = new VerticalLightAngleVoxelColorPicker.VerticalEdge();
		colorUtils.getPathDeltas(
				0, 0, 0, 
				terrain, 
				3, 0, 2, 
				ColorUtils.XZ_LEFT_HANDED, 
				ColorUtils.XZ_RIGHT_HANDED, 
				true, 
				result, 
				turn3,
				false
		);
		System.out.println( result );
		System.out.println( turn3 );
	}
}
